<template>
	<view class="content">
		<view class="logo">
			<view style="height: 480rpx;"></view>
			<image src="../../static/login/logo.png" mode=""></image>
		</view>
		<view class="box">
			<view class="item">
				<view class="item-left">
					<image src="../../static/login/incon1.png" mode=""></image>
					<view class="item-text">
						<u-input placeholder="请输入账号" border="none" v-model="phone"></u-input>
					</view>
				</view>
			</view>
			<view class="item">
				<view class="item-left">
					<image src="../../static/login/incon2.png" mode=""></image>
					<view class="item-text">
						<u-input :type="type" placeholder="请输入密码" border="none" v-model="password"></u-input>
					</view>
				</view>
				<image v-if="type == 'password'" class="right-icon" src="../../static/login/see0.png" mode=""
					@click="type = 'text'"></image>
				<image v-else class="right-icon" src="../../static/login/see1.png" mode="" @click="type = 'password'">
				</image>
			</view>
			<view class="btn">
				<u-button size="large" @click="gologin" color="linear-gradient( 90deg, #FE8A03 0%, #FA5900 100%)"
					type="primary" text="登录"></u-button>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone: '',
				password: '',
				code: '',
				type: 'password'
			}
		},
		onLoad() {

		},
		methods: {
			gologin() {
				if (this.phone == '') {
					uni.showToast({
						title: '请输入您的账号！',
						icon: 'none'
					})
					return
				}
				if (this.password == '') {
					uni.showToast({
						title: '请输入您的密码！',
						icon: 'none'
					})
					return
				}
				let params = {
					username: this.phone,
					password: this.password
				}
				uni.showLoading({
					mask: true
				})
				this.$Request({
					method: 'POST',
					url: '/api/login',
					data: params,
					ismsg: true,
				}).then(res => {
					uni.hideLoading()
					console.log(res)
					if (res.code == 200) {
						uni.setStorageSync('token', res.token);
						setTimeout(()=>{
							uni.reLaunch({
								url:'/pages/index/index'
							})
						},1000)
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background-image: url('../../static/login/login-bg.png');
		background-repeat: no-repeat;
		background-size: 100% 756rpx;
		min-height: 100vh;

		.logo {
			text-align: center;

			image {
				width: 200rpx;
				height: 200rpx;
				border-radius: 30rpx;
			}

		}

		.box {
			padding: 30rpx 50rpx;

			.item {
				padding: 30rpx;
				border-radius: 50rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				border: 1rpx solid #E7E7E7;
				margin-bottom: 30rpx;

				.item-left {
					display: flex;
					align-items: center;

					image {
						width: 30rpx;
						height: 40rpx;
					}

					.item-text {
						margin-left: 30rpx;
					}
				}

				.right-icon {
					width: 30rpx;
					height: 25rpx;
				}
			}

			.btn {
				margin-top: 50rpx;
				border-radius: 20rpx;
				overflow: hidden;
			}
		}
	}
</style>